<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑健康评价与指导从表</title>
	<#include "/common/resource.ftl">
	<script type="text/javascript">
		$(function () {
			<#if (params.healthId)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/elderHealthEvaluation/query.json',
					data: {elderHealthId: "${params.healthId}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
						    if (key == 'healthGuide') {
                                var healthGuide = record.healthGuide;
                                var healthGuideArray = healthGuide.split(",");
                                var healthGuideAll = $("input[name='healthGuide']");
                                for(var i=0; i<healthGuideArray.length; i++){
                                    debugger;
                                    //获取所有复选框对象的value属性，然后，symptomArray[i]和他们匹配，如果有，则说明他应被选中
                                    $.each(healthGuideAll,function(j,checkbox){
                                        //获取复选框的value属性
                                        var checkValue = $(checkbox).val();
                                        if(healthGuideArray[i] == checkValue){
                                            $(checkbox).attr("checked",true);
                                            $(checkbox).next().addClass('layui-form-checked');
                                        }
                                    });
                                }
                            } else if (key == 'dangerControl') {
                                var dangerControl = record.dangerControl;
                                var dangerControlArray = dangerControl.split(",");
                                var dangerControlAll = $("input[name='dangerControl']");
                                for(var i=0; i<dangerControlArray.length; i++){
                                    debugger;
                                    //获取所有复选框对象的value属性，然后，symptomArray[i]和他们匹配，如果有，则说明他应被选中
                                    $.each(dangerControlAll,function(j,checkbox){
                                        //获取复选框的value属性
                                        var checkValue = $(checkbox).val();
                                        if(dangerControlArray[i] == checkValue){
                                            $(checkbox).attr("checked",true);
                                            $(checkbox).next().addClass('layui-form-checked');
                                        }
                                    });
                                }
                            } else {
						        $("[name='" + key + "']").val(record[key]);
                            }
						}
                        var form = layui.form;
                        form.render();
					}
				});
			</#if>
		});
	</script>
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <style>
        .layui-form select {display:none !important;}
    </style>
</head>
<body>
	<div class="ui-form">
        <#if (params.healthId)??>
		<form class="layui-form ajax-form" action="${params.contextPath}/web/elderHealthEvaluation/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="elderHealthId" value="${params.healthId}" />
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <label class="layui-form-label">体检是否有异常<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="isException">
                                        <option value="">请选择</option>
                                        <option value="体检无异常">体检无异常</option>
                                        <option value="有异常">有异常</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">异常1<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="exception1" placeholder="请输入异常" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">异常2<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="exception2" placeholder="请输入异常" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">异常3<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="exception3" placeholder="请输入异常" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">异常4<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="exception4" placeholder="请输入异常" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <label class="layui-form-label">健康指导<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="healthGuide" value="纳入慢性病患者健康管理" title="纳入慢性病患者健康管理">
                                    <input type="checkbox" name="healthGuide" value="建议复查" title="建议复查">
                                    <input type="checkbox" name="healthGuide" value="建议转诊" title="建议转诊">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <label class="layui-form-label">危险因素控制<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="dangerControl" value="戒烟" title="戒烟">
                                    <input type="checkbox" name="dangerControl" value="健康饮酒" title="健康饮酒">
                                    <input type="checkbox" name="dangerControl" value="饮食" title="饮食">
                                    <input type="checkbox" name="dangerControl" value="锻炼" title="锻炼">
                                    <input type="checkbox" name="dangerControl" value="减体重" title="减体重">
                                    <input type="checkbox" name="dangerControl" value="建议接种疫苗" title="建议接种疫苗">
                                    <input type="checkbox" name="dangerControl" value="其他" title="其他">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">目标体重<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="targetWeight" placeholder="请输入目标体重" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">接种疫苗<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="vaccinum" placeholder="请输入接种疫苗" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">其他危险因素<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="dangerControlOther" placeholder="请输入其他危险因素" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
        <#else>
            请先保存老人健康基本信息!
        </#if>
    </div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
<script>
    $(function () {
        var form = layui.form;
        form.render();
    })
</script>
</html>
